<template>
    <div>
      <!--  修改是 显示弹窗  -->
        <el-button v-permission="['admin']" @click="handleClick(scope)" type="text" size="small">修改</el-button>
        <el-button  v-clipboard:copy="content(scope)"   v-clipboard:success="onCopy"      v-clipboard:error="onError"  type="text" size="small">复制</el-button>
        <el-button v-permission="['admin']" @click="handleClick2(scope)" type="text" size="small">删除</el-button>
      <!-- 
        删除是发送网络请求, 成功后 隐藏当前行
        scope 给的数据是 当前行 ,不是整个表单中 tabledata  =>如果要实现隐藏 tabedata.splice(scope.$index,1)

        子不能改父   

        我们想要实现 子改父 =>  vuex   => 父子通讯


       -->


      <div>
        <el-dialog     :modal="false" :visible.sync="dialogVisible">
          <div style="padding-left: 50px;">
            <Part     :id="Selectionid"></Part>
          </div>
   
      </el-dialog>

      </div>
      <el-dialog :modal="false" title="提示" :visible.sync="showIshot" width="30%">
            <span>确认删除?</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="(showIshot=false)">取 消</el-button>
                <el-button type="primary" @click="todelete">确 定</el-button>
            </span>
        </el-dialog>
 
    </div>
</template>

<script>
import {deletenovel} from '@/api/novel'
import Part from '@/components/novel/part.vue'
    export default {
        name:"changepass",
        props:['scope'],
        data() {
 


            return {
              Selectionid:"",
                dialogVisible:false,
                showIshot:false,
                index:-1,

  
      
            }
        },
        methods: {
          content(scope){
            var {id} = JSON.parse( localStorage.getItem('userinfo'))
            
              return  `http://readanovel.cn/#/reader/${scope.row.id}/1?id=${id}`
              // return  'https://dreame.jinghuanqiu.com/#/reader/13/6?id='
          },
          
          onCopy(){
              this.$msg( 
    { 
      message: '复制成功',
      type: 'success',
      duration: 1 * 1000
    }

                )
            
            
            },
            onError(){
              this.$msg( 
    { 
      message: '复制失败',
      type: 'fail',
      duration: 1 * 1000
    }

                )
            
            
            },

            handleClick(scope){
                // console.log(123465,scope);
                this.dialogVisible = true
                // console.log(scope.row);
                this.Selectionid = scope.row.id
             this.index = scope.$index
                
            },
            handleClick2(scope){
                // console.log(123465,scope);
                this.showIshot = true
                // console.log(scope.row);
                this.Selectionid = scope.row.id
                console.log(scope);
                this.index = scope.$index
            },
            handleClose(){
                this.dialogVisible = false
            },
            async todelete(){
               console.log(123, this.Selectionid );
              await   deletenovel({  id:  this.Selectionid })
              // this.showIshot = false
              var index = this.index
              this.showIshot = false
              this.$emit('childchange',  {  fn: function(data){
                          data.splice(index,1)
                } }  )


            }
        },
        components:{
          'Part':Part
        }
    }
</script>

<style lang="scss" scoped>

</style>